#include <stdio.h>
#include <stdlib.h>

#include "guess.h"
#include "click.h"
#include "carton.h"
#include "color.h"
#include "configuration.h"
#include "leaderboard.h"
#include "homepage.h"

#define UNUSED_PARAMETER(x) (void)x

int main(int argc, char **argv)
{
    char input_main_menu[32];

	UNUSED_PARAMETER(argc);
	UNUSED_PARAMETER(argv);

	leaderboard_init();
	system("clear");
	player_name();
    show_main_menu();

	while (1) {
        set_buffered_input(false);
		input_main_menu[0] = getchar();
        set_buffered_input(true);

		switch (input_main_menu[0]) {
			case CLICK:
				system("clear");
				show_click_menu();
				choice_click_menu();
				break;

			case GUESS:
				system("clear");
				show_guess_menu();
				choice_guess_menu();
				break;

			case LEADERBOARD:
				system("clear");
				main_board();
				break;

            case QUIT_MAIN:
				system("clear");
            	show_main_menu();
				printf(L_RED "\n\tWhether to QUIT(y/n):" NONE);
                set_buffered_input(false);
				input_main_menu[0] = getchar();
                set_buffered_input(true);

				if (input_main_menu[0] == 'y') {
					putchar('\n');
                    system("clear");
                	exit(EXIT_SUCCESS);
				} else {
					system("clear");
                	show_main_menu();
					choice_main_menu();
				}
				break;

			default :
				continue;
		}
	}

    return 0;
}
